package com.ruoyi.project.channel.bankInfo.service;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.utils.security.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.channel.bankInfo.mapper.BankInfoMapper;
import com.ruoyi.project.channel.bankInfo.domain.BankInfo;
import com.ruoyi.project.channel.bankInfo.service.IBankInfoService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 银行卡 服务层实现
 *
 * @author zero
 * @date 2019-05-04
 */
@Service
public class BankInfoServiceImpl implements IBankInfoService {
    @Autowired
    private BankInfoMapper bankInfoMapper;

    /**
     * 查询银行卡信息
     *
     * @param bankId 银行卡ID
     * @return 银行卡信息
     */
    @Override
    public BankInfo selectBankInfoById(String bankId) {
        return bankInfoMapper.selectBankInfoById(bankId);
    }

    /**
     * 查询银行卡列表
     *
     * @param bankInfo 银行卡信息
     * @return 银行卡集合
     */
    @Override
    public List<BankInfo> selectBankInfoList(BankInfo bankInfo) {
        return bankInfoMapper.selectBankInfoList(bankInfo);
    }

    /**
     * 新增银行卡
     *
     * @param bankInfo 银行卡信息
     * @return 结果
     */
    @Override
    public int insertBankInfo(BankInfo bankInfo) {
        bankInfo.setCreateBy(ShiroUtils.getLoginName());
        bankInfo.setCreateTime(new Date());
        if (bankInfo.getUserId() == null) {
            bankInfo.setUserId(ShiroUtils.getUserId());
        }
        return bankInfoMapper.insertBankInfo(bankInfo);
    }

    /**
     * 修改银行卡
     *
     * @param bankInfo 银行卡信息
     * @return 结果
     */
    @Override
    public int updateBankInfo(BankInfo bankInfo) {
        bankInfo.setUpdateTime(new Date());
        return bankInfoMapper.updateBankInfo(bankInfo);
    }

    /**
     * 删除银行卡对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteBankInfoByIds(String ids) {
        return bankInfoMapper.deleteBankInfoByIds(Convert.toStrArray(ids));
    }

}
